package com.jilujia.framework.audit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContextHolder;

import com.jilujia.framework.security.JilujiaUser;


public class PoEntityAuditorAwareImpl implements PoEntityAuditorAware<JilujiaUser> {

	private static final Logger LOG = LoggerFactory.getLogger(PoEntityAuditorAwareImpl.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.AuditorAware#getCurrentAuditor()
	 */
	public JilujiaUser getCurrentAuditor() {
		JilujiaUser currentUser = (JilujiaUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return currentUser;
	}

	public String getCurrentAuditorId() {
		JilujiaUser currentUser = (JilujiaUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		Long currentUserId = currentUser.getUserId();
		return currentUserId.toString();
	}

}
